package com.pinda.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.pinda.base.entity.PdTransportTripsTruckDriver;
import com.pinda.mapper.PdTransportTripsTruckDriverMapper;
import com.pinda.service.IPdTransportTripsTruckDriverService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 车次与车辆和司机关联表 服务实现类
 * </p>
 *
 * @author lc
 * @since 2023-06-14
 */
@Service
public class PdTransportTripsTruckDriverServiceImpl extends ServiceImpl<PdTransportTripsTruckDriverMapper, PdTransportTripsTruckDriver> implements IPdTransportTripsTruckDriverService {
    @Override
    public List<PdTransportTripsTruckDriver> findAll(String transportTripsId, String truckId, String userId) {
        LambdaQueryWrapper<PdTransportTripsTruckDriver> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotEmpty(transportTripsId)) {
            lambdaQueryWrapper.eq(PdTransportTripsTruckDriver::getTransportTripsId, transportTripsId);
        }
        if (StringUtils.isNotEmpty(truckId)) {
            lambdaQueryWrapper.eq(PdTransportTripsTruckDriver::getTruckId, truckId);
        }
        if (StringUtils.isNotEmpty(userId)) {
            lambdaQueryWrapper.eq(PdTransportTripsTruckDriver::getUserId, userId);
        }
        return baseMapper.selectList(lambdaQueryWrapper);
    }
}
